<?php
/**
 * 文章验证器
 */

namespace app\common\validate;

class ArticleValidate extends CommonBaseValidate
{
    protected $rule = [
            'user_id|用户' => 'require',
    'type|帖子分类' => 'require',
    'title|标题' => 'require',
    'files|图片/视频' => 'require',
    'content|内容' => 'require',
    'views|浏览量' => 'require|number',
    'comments|评论量' => 'require|number',
    'likes|点赞量' => 'require|number',
    'shop_id|商户' => 'require',
    'status|状态' => 'require',
    'top|是否置顶' => 'require',
    'sort|排序' => 'require|number',

    ];

    protected $message = [
            'user_id.required' => '用户不能为空',
    'type.required' => '帖子分类不能为空',
    'title.required' => '标题不能为空',
    'files.required' => '图片/视频不能为空',
    'content.required' => '内容不能为空',
    'views.required' => '浏览量不能为空',
    'views.number' => '浏览量必须为纯数字',
    'comments.required' => '评论量不能为空',
    'comments.number' => '评论量必须为纯数字',
    'likes.required' => '点赞量不能为空',
    'likes.number' => '点赞量必须为纯数字',
    'shop_id.required' => '商户不能为空',
    'status.required' => '状态不能为空',
    'top.required' => '是否置顶不能为空',
    'sort.required' => '排序不能为空',
    'sort.number' => '排序必须为纯数字',

    ];

    protected $scene = [
        'admin_add'     => ['user_id', 'type', 'title', 'files', 'content', 'views', 'comments', 'likes', 'shop_id', 'status', 'top', 'sort', ],
        'admin_edit'    => ['id', 'user_id', 'type', 'title', 'files', 'content', 'views', 'comments', 'likes', 'shop_id', 'status', 'top', 'sort', ],
        'admin_del'     => ['id', ],
        'admin_disable' => ['id', ],
        'admin_enable'  => ['id', ],
        'api_add'       => ['user_id', 'type', 'title', 'files', 'content', 'views', 'comments', 'likes', 'shop_id', 'status', 'top', 'sort', ],
        'api_info'      => ['id', ],
        'api_edit'      => ['id', 'user_id', 'type', 'title', 'files', 'content', 'views', 'comments', 'likes', 'shop_id', 'status', 'top', 'sort', ],
        'api_del'       => ['id', ],
        'api_disable'   => ['id', ],
        'api_enable'    => ['id', ],
    ];
}
